<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\models\LolHeros */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('model-lolheros', 'Lol Heros'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="lol-heros-view">

    <p>
        <?= Html::a(Yii::t('model-lolheros', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a(Yii::t('model-lolheros', 'Delete'), ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => Yii::t('model-lolheros', 'Are you sure you want to delete this item?'),
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'name',
            [
                "label" => "英雄",
                "value" => function ($model) { 
                    
                    return $model->title_name . ' - ' . $model->name_cn; 
                }
            ],
            [
                "label" => "职阶",
                "value" => function ($model) { 
                    $tags = explode(',', $model->tags);
                    array_walk($tags, function(&$val){
                        return $val = Yii::t('model-lolheros', $val);
                    });
                    return implode(',  ', $tags); 
                },
            ],
            'extend:ntext',
            'info',
            [
                "label" => "基础信息",
                "format" => [
                    "image", 
                    [
                        "width"=>"84",
                        "height"=>"84"
                    ]
                ],
                "value" => function ($model) { 
                    return $model->img; 
                },
                'options' => ['class' => 'json-data'],
            ],
            'extend:ntext',
        ],
    ]) ?>

</div>
<?php
$this->registerJsFile('@web/static/js/color-json.js',['depends' => 'app\assets\AppAsset']);
$js = <<<'js'
$($('#w0 tr').get(4)).find('td').jsonColorful();
js;
$this->registerJs($js);
?>